package com.ruoyi.hydrology.service.impl;

import java.util.List;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; //添加
import com.ruoyi.hydrology.domain.Jslcdss;
import com.ruoyi.hydrology.dto.HydrologyDto;
import com.ruoyi.hydrology.mapper.JslcdssMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.hydrology.mapper.JslcddyMapper;
import com.ruoyi.hydrology.domain.Jslcddy;
import com.ruoyi.hydrology.service.IJslcddyService;

/**
 * 降水量基础信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-06
 */
@Service
public class JslcddyServiceImpl extends ServiceImpl<JslcddyMapper, Jslcddy> implements IJslcddyService //修改
{
    @Autowired
    private JslcddyMapper jslcddyMapper;
    @Autowired
    private JslcdssMapper jslcdssMapper;
    /**
     * 查询降水量基础信息
     * 
     * @param id 降水量基础信息主键
     * @return 降水量基础信息
     */
    @Override
    public Jslcddy selectJslcddyById(String id)
    {
        return jslcddyMapper.selectJslcddyById(id);
    }

    /**
     * 查询降水量基础信息列表
     * 
     * @param jslcddy 降水量基础信息
     * @return 降水量基础信息
     */
    @Override
    public List<Jslcddy> selectJslcddyList(Jslcddy jslcddy)
    {
        return jslcddyMapper.selectJslcddyList(jslcddy);
    }

    /**
     * 新增降水量基础信息
     * 
     * @param jslcddy 降水量基础信息
     * @return 结果
     */
    @Override
    public int insertJslcddy(Jslcddy jslcddy)
    {
        return jslcddyMapper.insertJslcddy(jslcddy);
    }

    /**
     * 修改降水量基础信息
     * 
     * @param jslcddy 降水量基础信息
     * @return 结果
     */
    @Override
    public int updateJslcddy(Jslcddy jslcddy)
    {
        return jslcddyMapper.updateJslcddy(jslcddy);
    }

    /**
     * 批量删除降水量基础信息
     * 
     * @param ids 需要删除的降水量基础信息主键
     * @return 结果
     */
    @Override
    public int deleteJslcddyByIds(String[] ids)
    {
        return jslcddyMapper.deleteJslcddyByIds(ids);
    }

    /**
     * 删除降水量基础信息信息
     * 
     * @param id 降水量基础信息主键
     * @return 结果
     */
    @Override
    public int deleteJslcddyById(String id)
    {
        return jslcddyMapper.deleteJslcddyById(id);
    }

    @Override
    public Jslcddy selectJslcddyByCode(String stationCode) {
        return jslcddyMapper.selectJslcddyByCode(stationCode);
    }

    @Override
    public List<HydrologyDto> getHydrology() {
        List<HydrologyDto> jslcddys = jslcddyMapper.getHydrology();
        List<HydrologyDto> collect = jslcddys.stream().map(jslcddy -> {
            Jslcdss jslcdss = jslcdssMapper.selectJslcdssByCode(jslcddy.getStationCode());
            jslcddy.setMeasureName("降水量");
            jslcddy.setValue(jslcdss.getValue().toString());
            jslcddy.setMonitorTime(jslcdss.getMonitorTime());
            jslcddy.setSensorType("1");
            return jslcddy;
        }).collect(Collectors.toList());
        return collect;
    }
}
